﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Comod_DrawPrint2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            
                ZSql zsql = new ZSql();


                string sql = "select ComoditiesId,comodicode,b.WarehouseName,c.Supplier,d.ComoditiesType,e.Brand,f.ComoditiesName,i.Specifications,j.Units,convert(char(10),storageTime,120) as storDate ,a.comodid,ComoditiesBarcode,Prices1,Prices2,SeveralStorage,TotalMoney,a.EditUserName,a.AuditState from CS_Comoditiles a join CS_Warehouse b on a.WarehouseId=b.WarehouseId join CS_Supplier c on a.SupplierId=c.SupplierId join ComoditiesType d on a.ComoditiesType=d.TypeId join Brand e on a.brand=e.BrandId join ComoditiesName f on a.ComoditiesName=f.ComoditiesNameId join Specifications i on a.Specifications=i.SpecificationsId join Units j on a.Units=j.UnitsId where 1=1";

                if (Request["all"]=="tj")
                {
                    if (!string.IsNullOrEmpty(Request["gettim1"]) && !string.IsNullOrEmpty(Request["gettim2"]))
                    {
                        sql += " and storageTime>='" + Request["gettim1"] + " 00:00:00' and storageTime<='" + Request["gettim2"] + " 23:59:59'";
                    }
                    if (!string.IsNullOrEmpty(Request["type"]))
                    {
                        sql += " and d.ComoditiesType='" + Request["type"] + "'";
                    }
                    if (!string.IsNullOrEmpty(Request["name"]))
                    {
                        sql += " and e.Brand='" + Request["name"] + "'";
                    }
                    if (!string.IsNullOrEmpty(Request["modul"]))
                    {
                        sql += " and i.Specifications='" + Request["modul"] + "'";
                    }
                }
                zsql.Open(sql);
                DataTable dt = new DataTable();
                string strTable = "";
                dt = zsql.m_table;

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        strTable += "<div align=\"center\">入库清单</div>";
                        strTable += "<table width=\"97%\" border=\"1\"><tr><td align=\"center\">单号</td><td align=\"center\">所在仓库</td><td align=\"center\">供货商</td><td align=\"center\">品牌</td><td align=\"center\">名称</td><td align=\"center\">型号</td><td align=\"center\">数量</td><td align=\"center\">单位</td><td align=\"center\">入库日期</td></tr>";


                        for (int i = 0; i < zsql.m_table.Rows.Count; i++)
                        {
                            strTable += "<tr><td align=\"center\">" + zsql.m_table.Rows[i]["comodicode"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["WarehouseName"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["Supplier"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["Brand"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["ComoditiesName"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["Specifications"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["SeveralStorage"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["Units"].ToString() + "</td><td align=\"center\">" + zsql.m_table.Rows[i]["storDate"].ToString() + "</td></tr>";

                        }
                        strTable += "</table>";
                    }
                }
                zsql.Close();

                lblTable.Text = strTable;
            
        }
    }
}
